function resultMessage() {
    var self = this;
    self.jsonObj = {
        code: 0,
        msg: ""
    };
    return self;
}

resultMessage.prototype.ok = function (obj) {
    var self = this;
    self.jsonObj = {
        code: 0,
        msg: obj
    };
    return self;
};

resultMessage.prototype.error = function (...params) {
    var self = this;
    if (!params) {
        self.jsonObj = {
            code: 500,
            msg: "未知异常，请联系管理员！"
        };
    }
    var iLen = params.length;
    switch (iLen) {
        case 1:
            self.jsonObj = {
                code: 500,
                msg: params[0]
            };
            break;
        case 2:
            self.jsonObj = {
                code: params[0],
                msg: params[1]
            };
            break;
        default:
            break;
    }
    return self;
};

resultMessage.prototype.toString = function () {
    var self = this;
    return JSON.stringify(self.jsonObj);
};

module.exports = resultMessage;